<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Make Controller Kit - Firmware API: Stepper - OSC</title>
<link href="mt_doxygen.css" rel="stylesheet" type="text/css" />
<link href="../resources/mt_doxytabs.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.header {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12pt;
	color: #222222;
}
-->
</style>
</head>

<body>
<table width="800" border="0">
    <tr>
      <td colspan="3">
        <form method="get" action="http://www.google.com/search">
          <div align="right">
            <input type="text"   name="q" size="25"
              maxlength="255" value="" />
            <input type="submit" value="Search" />
            <input type="hidden" name="sitesearch" value="makingthings.com/ref/firmware/html" />
          </div>
        </form>
       </td>
    </tr>
    <tr>
      <td><div align="center"><a href="http://www.makingthings.com">
				<img src="../resources/logo_brown_medium.png" alt="MakingThings"
									width="200" height="78" border="0" align="middle" longdesc="http://www.makingthings.com" /></a></div></td>
				<td><div align="center" class="header">
      		Make Controller Kit <br />
          Firmware API
      </div></td>
      <td><div align="center"><a href="http://www.makezine.com">
					<img src="../resources/make_logo.png" alt="MAKE Zine" 
										width="164" height="73" border="0" align="middle" longdesc="http://www.makezine.com" /></a></div></td>
    </tr>
</table>
</body>
</html>
<!-- Generated by Doxygen 1.5.4 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
  var num=this.id.replace(/[^[0-9]/g,'');
  var button=this.firstChild;
  var sectionDiv=document.getElementById('dynsection'+num);
  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
    sectionDiv.style.display='block';
    button.src='open.gif';
  }else{
    sectionDiv.style.display='none';
    button.src='closed.gif';
  }
}
function initDynSections(){
  var divs=document.getElementsByTagName('div');
  var sectionCounter=1;
  for(var i=0;i<divs.length-1;i++){
    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
      var header=divs[i];
      var section=divs[i+1];
      var button=header.firstChild;
      if (button!='IMG'){
        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
        button=document.createElement('img');
        divs[i].insertBefore(button,divs[i].firstChild);
      }
      header.style.cursor='pointer';
      header.onclick=changeDisplayState;
      header.id='dynheader'+sectionCounter;
      button.src='closed.gif';
      section.id='dynsection'+sectionCounter;
      section.style.display='none';
      section.style.marginLeft='14px';
      sectionCounter++;
    }
  }
}
window.onload = initDynSections;
-->
</script>
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<h1>Stepper - OSC<br>
<small>
[<a class="el" href="group___o_s_c.html">OSC</a>]</small>
</h1>Control Stepper motors with the Application Board via OSC.  
<a href="#_details">More...</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
</table>
Specify settings for your stepper motor by setting whether it's:<ul>
<li>bipolar or unipolar</li><li>normal of half-stepping</li></ul>
<p>
You can generally use the stepper motor in 2 modes - <b>absolute</b> positioning or <b>relative</b> positioning.<p>
For absolute positioning, set <b>positionrequested</b> with the desired position, and the motor will move there. You can read back the stepper's <b>position</b> property at any point along the way to determine where it is at a given moment. The board keeps an internal count of how many steps the motor has taken in order to keep track of where it is.<p>
For relative positioning, use the <b>step</b> property to simply move a number of steps from the current position.<h2><a class="anchor" name="devices">
Devices</a></h2>
There are 2 Stepper controllers available on the Application Board, numbered 0 &amp; 1. See the Stepper section in the Application Board user's guide for more information on hooking steppers up to the board.<h2><a class="anchor" name="properties">
Properties</a></h2>
Each stepper controller has eight properties:<ul>
<li>position</li><li>positionrequested</li><li>speed</li><li>duty</li><li>bipolar</li><li>halfstep</li><li>step</li><li>active</li></ul>
<p>
<dl class="user" compact><dt><b>Step</b></dt><dd>The <b>step</b> property simply tells the motor to take a certain number of steps. This is a write-only value. </dd></dl>
<dl class="user" compact><dt><b></b></dt><dd>To take 1000 steps with the first stepper, send the message <div class="fragment"><pre class="fragment">/stepper/0/step 1000</pre></div></dd></dl>
<dl class="user" compact><dt><b>Position</b></dt><dd>The <b>position</b> property corresponds to the current step position of the stepper motor This value can be both read and written. Writing this value changes where the motor thinks it is. The initial value of this parameter is 0. </dd></dl>
<dl class="user" compact><dt><b></b></dt><dd>To set the first stepper to step position 10000, send the message <div class="fragment"><pre class="fragment">/stepper/0/position 10000</pre></div> Leave the argument value off to read the position of the stepper: <div class="fragment"><pre class="fragment">/stepper/0/position </pre></div></dd></dl>
<dl class="user" compact><dt><b>PositionRequested</b></dt><dd>The <b>positionrequested</b> property describes the desired step position of the stepper motor This value can be both read and written. Writing this value changes the motor's destination. </dd></dl>
<dl class="user" compact><dt><b></b></dt><dd>To set the first stepper to go to position 10000, send the message <div class="fragment"><pre class="fragment">/stepper/0/positionrequested 10000</pre></div> Leave the argument value off to read the last requested position of the stepper: <div class="fragment"><pre class="fragment">/stepper/0/positionrequested </pre></div></dd></dl>
<dl class="user" compact><dt><b>Speed</b></dt><dd>The <b>speed</b> property corresponds to the speed with which the stepper responds to changes of position. This value is the number of milliseconds between each step. So, a speed of one would be a step every millisecond, or 1000 steps a second. </dd></dl>
<dl class="user" compact><dt><b></b></dt><dd>Note that not all stepper motors can be stepped quite that fast. If you find your stepper motor acting strangely, experiment with slowing down the speed a bit. </dd></dl>
<dl class="user" compact><dt><b></b></dt><dd>To set the speed of the first stepper to step at 100ms per step, send a message like <div class="fragment"><pre class="fragment">/stepper/0/speed 100 </pre></div> Adjust the argument value to one that suits your application.<br>
 Leave the argument value off to read the speed of the stepper: <div class="fragment"><pre class="fragment">/stepper/0/speed </pre></div></dd></dl>
<dl class="user" compact><dt><b>Duty</b></dt><dd>The <b>duty</b> property corresponds to the how much of the power supply is to be sent to the stepper. This is handy for when the stepper is static and not being required to perform too much work and reducing its power helps reduce heat dissipation. This value can be both read and written, and the range of values is 0 - 1023. A duty of 0 means the stepper gets no power, and the value of 1023 means the stepper gets full power. </dd></dl>
<dl class="user" compact><dt><b></b></dt><dd>To set the duty of the first stepper to 500, send a message like <div class="fragment"><pre class="fragment">/stepper/0/duty 500 </pre></div> Adjust the argument value to one that suits your application.<br>
 Leave the argument value off to read the duty of the stepper: <div class="fragment"><pre class="fragment">/stepper/0/duty </pre></div></dd></dl>
<dl class="user" compact><dt><b>Bipolar</b></dt><dd>The <b>bipolar</b> property is set to the style of stepper being used. A value of 1 specifies bipolar (the default) and 0 specifies a unipolar stepper. This value can be both read and written.</dd></dl>
<dl class="user" compact><dt><b>HalfStep</b></dt><dd>The <b>halfstep</b> property controls whether the stepper is being half stepped or not. A 0 here implies full stepping (the default) and 1 implies a half stepping. This value can be both read and written.</dd></dl>
<dl class="user" compact><dt><b>Active</b></dt><dd>The <b>active</b> property corresponds to the active state of the stepper. If the stepper is set to be active, no other tasks will be able to write to the same I/O lines. If you're not seeing appropriate responses to your messages to a stepper, check the whether it's locked by sending a message like <div class="fragment"><pre class="fragment">/stepper/1/active </pre></div> </dd></dl>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Make Controller Kit</title>
<style type="text/css">
<!--
.footer {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9pt;
	color: #999999;
}
-->
</style>
</head>

<body>
<hr size="1">
<div>
  <p class="footer">The Make Controller Kit is an open source project maintained by <a href="http://www.makingthings.com">MakingThings</a>.<br />
    MakingThings code is released under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache 2.0 license</a>.<br />
    Bug tracker, development wiki and status can be found at <a href="http://dev.makingthings.com">http://dev.makingthings.com</a>.<br />
		This document was last updated on 5 Dec 2007.
</p>
</div>
<!-- Google Analytics Code -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-769030-1";
urchinTracker();
</script>
</body>
</html>
